#!/usr/bin/env python
# @FileName :01-20.py
# @Time :2024/1/20 19:57
# @Author :qiqianxu

def login(username1, password1):
    cnt = 0
    print("欢迎进入登录系统！")
    while 1:
        print("请输入用户名和密码")
        name = input()
        passwd = input()
        if name == username1 and passwd == password1:
            print("登录成功！")
            return True
        cnt += 1
        if cnt >= 3:
            print("失败次数太多，无法继续登录")
            break
        print("登录失败，请重试！")
        print(f"您还有{cnt}次机会")
    return False


def system(bal):
    print("欢迎进入存取款系统")
    while 1:
        print("请输入选项：")
        print("1.存款")
        print("2.取款")
        print("3.查询余额")
        print("4.退出系统")
        choice = int(input())
        if choice == 1:
            while 1:
                print("请输入您要存入的金额:")
                money = float(input())
                if money < 0:
                    print("金额不得小于零，请重试")
                    continue
                bal += money
                print(f"已成功存入{money:.2f}元")
                break
        elif choice == 2:
            while 1:
                print("请输入您要取出的金额:")
                money = float(input())
                if money < 0:
                    print("金额不得小于零，大于余额，请重试")
                    continue
                bal -= money
                print(f"已成功取出{money:.2f}元")
                break
        elif choice == 3:
            print(f"您目前的余额是{bal:.2f}元")
        elif choice == 4:
            print("已成功退出系统")
            break
        else:
            print("没有这个选项")


username = "root"
password = "123456"
balance = 1000.00
entry = login(username, password)
if entry:
    system(balance)
